package com.gem.springbootdemo.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

//购物车里面的商品

@NoArgsConstructor
@AllArgsConstructor
public class CarGood {
    //商品的详情
    private Goods goods;
    //购物车中商品的数量
    private  int num;
    //所属用户
    private User user;
    private double  sumPrice;

    public Goods getGoods() {
        return goods;
    }

    public void setGoods(Goods goods) {
        this.goods = goods;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public double getSumPrice() {
        return getGoods().getPrice()*getNum();
    }

    public void setSumPrice(double sumPrice) {
        this.sumPrice = sumPrice;
    }

    public CarGood(Goods goods, int num, User user) {
        this.goods = goods;
        this.num = num;
        this.user = user;
        sumPrice=this.num*this.goods.getPrice();
    }

    @Override
    public String toString() {
        return "CarGood{" +
                "goods=" + goods +
                ", num=" + num +
                ", user=" + user +
                ", sumPrice=" + sumPrice +
                '}';
    }
}
